package com.gudy.counter.service.impl;

import com.gudy.counter.bean.CounterRes;
import com.gudy.counter.bean.Transaction;
import com.gudy.counter.service.TranSactionService;
import com.gudy.counter.util.DBUtil;
import com.gudy.counter.util.TimeformatUtil;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

@Service
public class TranSactionServiceImpl implements TranSactionService {
    @Override
    public CounterRes rechargeAmount(Transaction transaction,String token) {
        Date date = new Date();
        transaction.setDate( TimeformatUtil.yyyyMMdd(date));
        transaction.setTime(  TimeformatUtil.hhMMss(date));
        return  DBUtil.saveTranSaction(transaction,token);
    }

    @Override
    public CounterRes queryTransaction(HttpServletRequest request) {
        String startDate = request.getParameter("startDate");
        String endDate = request.getParameter("endDate");
        String uid = request.getParameter("uid");
        return DBUtil.queryTransaction(startDate,endDate,uid);
    }
}
